package broadcast.jun.com.mybroadcastreceiver;

import android.content.Intent;
import android.content.IntentFilter;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

public class MainActivity extends AppCompatActivity {
    public  static final  String ACTION="broadcast.jun.com.mybroadcastreceiver";
    public IntentFilter mFilter;
    public MyReceiver myReceiver=new MyReceiver();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mFilter = new IntentFilter();
        mFilter.addAction(ACTION);
    }

    public void send(View v){
        Intent i=new Intent();
        i.setAction(ACTION);
        sendBroadcast(i);
    }

    public void reg(View view){
        registerReceiver(myReceiver,mFilter);
    }

    public  void unreg(View v){
        unregisterReceiver(myReceiver);
    }
}
